package com.mingyuan.library.infra.common.utils.validate;

import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * 对象属性校验结果
 * @author yangzhongkun
 * @date 2021/3/17 10:55
 * @Version 1.0
 **/
public class ValidationResult {
    private boolean hasErrors = false;
    private Map<String,String> errorMessages = new HashMap<> ();
    public String getErrorMessage() {
        return StringUtils.join(errorMessages.values().toArray(),",");
    }

    public boolean isHasErrors() {
        return hasErrors;
    }

    public void setHasErrors(boolean hasErrors) {
        this.hasErrors = hasErrors;
    }

    public Map<String, String> getErrorMessages() {
        return errorMessages;
    }

    public void setErrorMessages(Map<String, String> errorMessages) {
        this.errorMessages = errorMessages;
    }
    public ValidationResult() {
    }
    public ValidationResult(boolean hasErrors) {
        this.hasErrors = hasErrors;
    }
    public ValidationResult(boolean hasErrors, Map<String, String> errorMessages) {
        this.hasErrors = hasErrors;
        this.errorMessages = errorMessages;
    }




}
